﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq.Expressions;

namespace MyBasicLib.Data
{
    //public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, out TResult>(
    //    T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);

    //public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, out TResult>(
    //    T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);

    //public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, out TResult>(
    //    T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);

    //public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, out TResult>(
    //    T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);

    //public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, out TResult>(
    //    T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);


    public interface IDatabase
    {
        DbProviderFactory DbProviderFactory { get; }         
        string ConnectionString { get; set; }
        string ParameterToken { get; } 

        IDbConnection CreateConnection();
        IDbConnection CreateNewOpenConnection();
        IDbCommand CreateCommand(string commandText);
      
        int ExecuteNonQuery(IDbTransaction transaction, IDbCommand cmd);
        IDataReader ExecuteReader(IDbTransaction transaction, IDbCommand cmd);
        object ExecuteScalar(IDbTransaction transaction, IDbCommand sql);

        T Execute<T>(IDbTransaction transaction, IDbCommand cmd) ;
        T Execute<T>(IDbTransaction transaction, IDbCommand cmd, T t)  ;
        IEnumerable<T> ExecuteList<T>(IDbTransaction transaction, IDbCommand cmd) ;
        IEnumerable<T> ExecuteList<T>(IDbTransaction transaction, IDbCommand cmd, T t)  ;  
        
        IDbCommand GetStoredProcedure(string storedProcedureName, params object[] parameterValues);

        //T Execute<T>(IDbTransaction transaction, IDbCommand cmd, T t);
        //T Execute<T1, T>(IDbTransaction transaction, IDbCommand cmd, Expression<Func<T1, T>> t);
        //T Execute<T1, T2, T>(IDbTransaction transaction, IDbCommand cmd, Expression<Func<T1, T2, T>> t);
        //T Execute<T1, T2, T3, T>(IDbTransaction transaction, IDbCommand cmd, Expression<Func<T1, T2, T3, T>> t);



        //IEnumerable<T> ExecuteList<T>(IDbTransaction transaction, IDbCommand cmd, T t);
        //IEnumerable<T> ExecuteList<T1, T>(IDbTransaction transaction, IDbCommand cmd, Expression<Func<T1, T>> t);
        //IEnumerable<T> ExecuteList<T1, T2, T>(IDbTransaction transaction, IDbCommand cmd, Expression<Func<T1, T2, T>> t);

        //IEnumerable<T> ExecuteList<T1, T2, T3, T>(IDbTransaction transaction, IDbCommand cmd,
        //                                          Expression<Func<T1, T2, T3, T>> t);

        //IEnumerable<T> ExecuteList<T1, T2, T3, T4, T>(IDbTransaction transaction, IDbCommand cmd,
        //                                              Expression<Func<T1, T2, T3, T4, T>> t);

        //IEnumerable<T> ExecuteList<T1, T2, T3, T4, T5, T>(IDbTransaction transaction, IDbCommand cmd,
        //                                                  Expression<Func<T1, T2, T3, T4, T5, T>> t);

        //IEnumerable<T> ExecuteList<T1, T2, T3, T4, T5, T6, T>(IDbTransaction transaction, IDbCommand cmd,
        //                                                      Expression<Func<T1, T2, T3, T4, T5, T6, T>> t);

        //IEnumerable<T> ExecuteList<T1, T2, T3, T4, T5, T6, T7, T>(IDbTransaction transaction, IDbCommand cmd,
        //                                                          Expression<Func<T1, T2, T3, T4, T5, T6, T7, T>> t);

        //IEnumerable<T> ExecuteList<T1, T2, T3, T4, T5, T6, T7, T8, T>(IDbTransaction transaction, IDbCommand cmd,
        //                                                              Expression
        //                                                                  <Func<T1, T2, T3, T4, T5, T6, T7, T8, T>> t);

        //IEnumerable<T> ExecuteList<T1, T2, T3, T4, T5, T6, T7, T8, T9, T>(IDbTransaction transaction, IDbCommand cmd,
        //                                                                  Expression
        //                                                                      <
        //                                                                      Func
        //                                                                      <T1, T2, T3, T4, T5, T6, T7, T8, T9, T>> t);


        //IEnumerable<T> ExecuteList<T>(IDbTransaction transaction, string storedProcedureName,
        //                              params object[] parameterValues);

    }
}